import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

class HttpTransactionService {
  /// 获取设置数据
  static Future<Response> getTransaction({
    int page,
    String start_date,
    String end_date,
    String keyword,
    int contactId,
    List<String>
        type, //quotation,invoice,cash_in,purchase_order,bill,expense,cash_out
    List<String> status,
    int is_overdue,
  }) {
    return BaseConfig.httpBase.get('/api/transactions', {
      'page': page,
      if (start_date != null) ...{
        'start_date': start_date,
      },
      if (end_date != null) ...{
        'end_date': end_date,
      },
      if (contactId != null) ...{
        'contact_id': contactId,
      },
      if (type != null) ...{
        'types': type?.join(','),
      },
      if (status != null && status.length > 0) ...{
        'status': status?.join(','),
      },
      if (keyword != null && keyword.isNotEmpty) ...{
        'keyword': keyword,
      },
      if (is_overdue != null) ...{
        'is_overdue': is_overdue,
      },
    });
  }
}
